package les.anagrama;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.RadioButton;

public class Level extends Activity {
	les.anagrama.util.Level level;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.level);

		RadioButton level1 = (RadioButton) findViewById(R.id.radioButton1);
		level1.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				level = les.anagrama.util.Level.LEVEL_1;
			}
		});

		RadioButton level2 = (RadioButton) findViewById(R.id.radioButton2);
		level2.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				level = les.anagrama.util.Level.LEVEL_2;
			}
		});

		RadioButton level3 = (RadioButton) findViewById(R.id.radioButton3);
		level3.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				level = les.anagrama.util.Level.LEVEL_3;
			}
		});

		level = (les.anagrama.util.Level) getIntent().getExtras()
				.getSerializable("level");

		switch (level) {
		case LEVEL_1:
			level1.toggle();
			break;
		case LEVEL_2:
			level2.toggle();
			break;
		case LEVEL_3:
			level3.toggle();
			break;
		}
	}

	public void choose(View view) {
		super.onStop();
		Intent data = new Intent();
		data.putExtra("level", level);
		setResult(RESULT_OK, data);
		finish();
	}
}
